home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 363 / tprolog1 / toy.doc < prev    next >
Text File  |  1990-02-03  |  5KB  |  115 lines

  1.                A Little Unofficial Information on TOY Prolog
  2.  
  3. Several people have asked for some sort of documentation in english for TOY
  4. Prolog.  While I have not yet been able to get the docs translated, here is
  5. a summary of what I have been able to determine so far (correct me if I'm
  6. wrong!):
  7.  
  8. - TOY Prolog operates almost exactly like the system described in
  9.   'Programming in Prolog' by Clocksin & Mellish.  If you don't have
  10.   this book, GET IT.  You will be able to operate TOY Prolog from
  11.   the examples shown in the book.
  12.  
  13. - You may not enter facts or rules directly from the keyboard (it always
  14.   tries to evaluate them).  There are two ways that I have used to do this:
  15.  
  16.   (1) Use consult(user).  This will cause the interpreter to treat the
  17.       terminal as if it were a disk file.  You can enter anything you
  18.       like this way. Terminate the input with 'end.'.
  19.  
  20.   (2) Use assert.  If you press the <insert> key it will type 'assert('.
  21.       You can then enter a fact or rule, terminated with ').' and the
  22.       interpreter will accept it. For example,
  23.  
  24.         assert(likes(john,mary)).
  25.  
  26. - To load a database that you have created with a text editor enter
  27.  
  28.     consult('filename').
  29.  
  30.   For example, to load a file called DATABASE which is in a folder called
  31.   PROLOG on drive B enter
  32.  
  33.     consult('b:\prolog\database').
  34.  
  35.   The interpreter will read the file, typing it as it goes so that you
  36.   can see what is going on.
  37.  
  38. - After you have an application debugged you can 'pre-interpret' it so
  39.   that it will be stored in tokenized form and will load much faster.
  40.   To do this enter
  41.  
  42.     translate('oldfile','newfile').
  43.  
  44.   For example, to 'compile' the DATABASE file we used before enter
  45.  
  46.     translate('b:\prolog\database','b:\prolog\database.toy').
  47.  
  48.   To load a 'compiled' database use the 'sysload' predicate. For example,
  49.  
  50.     sysload('b:\prolog\database.toy').
  51.  
  52. - Use 'shift''alt''help' to interrupt the interpreter and enter the
  53.   debugger.  The debugger allows the following commands:
  54.  
  55.     A - Abort
  56.     B - Backtrace
  57.     C - Continue
  58.     D - Debug on/off (like 'debug' and 'nodebug')
  59.     F - Fail
  60.     S - Step
  61.  
  62. - To exit the interpreter (back to the desktop) enter 'stop.'.
  63.  
  64. - There are some differences between TOY prolog and the syntax described
  65.   in C & M.  Here are a few:
  66.  
  67.   (1) The 'name' predicate is called 'pname' and 'pnamei'. 'pnamei' treats
  68.       the list as a list of integers.  'pname' treats the list as a list of
  69.       symbols (characters?).
  70.  
  71.   (2) The 'findall' predicate is called 'bagof'.  It seems to operate
  72.       identically.
  73.  
  74.   (3) When a query succeeds you may ask for another solution by entering
  75.       ';', however, to stop execution and return to the '?-' prompt you
  76.       must enter '.', not just <CR> as in C & M.
  77.  
  78. - The editor utility ('editor.toy') will allow you to edit a predicate
  79.   that is made up of several clauses.  It will not allow you to edit
  80.   individual clauses.  It is invoked by entering edit(predicate/arity).
  81.   The following are the editor commands:
  82.  
  83.     e predicate/arity - invoke a new copy of the editor to edit another
  84.                         predicate. 
  85.     x                 - exit the current copy of the editor.
  86.     + or <CR>         - move to the next clause.
  87.     -                 - move to the previous clause.
  88.     t                 - move to clause 0.
  89.     b                 - move to the last clause.
  90.     l                 - list the entire predicate.
  91.     d                 - delete the current clause.
  92.     i                 - insert clauses ('end.' terminates input).
  93.     f filename        - insert clauses from a file.
  94.     p                 - invoke a new copy of the interpreter to test
  95.                         the predicate.
  96.  
  97. - The calltree utility ('calltree.toy') will display a tree diagram of
  98.   the predicates (and their arity) that are invoked when the target
  99.   predicate is invoked.  To use it enter 'calltree(predicate/arity)'.
  100.  
  101. There are a number of predicates present in TOY prolog that are not 
  102. mentioned in C & M.  I have not tried to determine what any of them do
  103. yet.  ST specific predicates are provided to set and read the time and
  104. date, interact with the terminal, and execute VDI functions.  While I
  105. have not tried to use them they seem fairly simple. Check the 'tictactoe'
  106. demo and the Abacus books.
  107.  
  108. I would encourage anyone else who is using TOY Prolog to download this
  109. file, fix my mistakes, and add whatever information you have.  Perhaps
  110. we can create our own documentation!
  111.  
  112.                                      Michael A. Long (MALONG)
  113.                                      8/28/87
  114.   
  115. əəəəəəəəəəəəəəəəəəəəəəəəəəəə